import { ref } from 'vue'
import { like } from '@/services/consult'
interface FollowItem {
  id: string
  likeFlag: 0 | 1
}

export function useFollowDoc() {
  // 将发请求的逻辑函数封装进这个组合式函数中，最后导出
  const loading = ref(false)
  const follow = async (item: FollowItem) => {
    loading.value = true
    await like(item.id)
    item.likeFlag = item.likeFlag === 0 ? 1 : 0
    loading.value = false
  }
  return {
    loading,
    follow
  }
}
